package com.xander.qqdatabase.controller;

import com.xander.qqdatabase.aop.Log;
import com.xander.qqdatabase.base.ResultBean;
import com.xander.qqdatabase.entity.QunInfo;
import com.xander.qqdatabase.enums.ErrorCodeEnum;
import com.xander.qqdatabase.service.QunInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 叶振东
 * @date 2019-01-23
 */
@RestController
@RequestMapping("quninfo")
public class QunInfoController {
    @Autowired
    private QunInfoService qunInfoService;

    @Log(note = "查询群信息")
    @RequestMapping("quninfo")
    public ResultBean searchQunInfoByQun(String qun) {
        String regex = "^[0-9]*[1-9][0-9]*$";
        if (!qun.matches(regex)) {
            return new ResultBean(ErrorCodeEnum.PARAMETER_EMPTY.getCode(), "请输入数字");
        }
        QunInfo qunInfo = qunInfoService.getQunInfo(Integer.valueOf(qun));
        return new ResultBean<>(qunInfo);
    }
}
